package com.information.manage.basic.model.query;

import com.information.manage.basic.common.utils.AESIVUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

@Data
@ApiModel("修改用户传参")
public class SysUserUpdateQuery {

    @ApiModelProperty("用户id")
    private Integer userId;

    @ApiModelProperty("用户名")
    private String userName;

    @ApiModelProperty("密码")
    private String password;

    @ApiModelProperty("角色id")
    private Integer roleId;

    @ApiModelProperty("描述")
    private String description;

    @ApiModelProperty(value = "用于AES解码的iv", required = false)
    private String iv;

    public String getPassword() {
        // 对密码进行解码
        String ivValue = getIv();
        if (StringUtils.isEmpty(ivValue)) return password; // 不存在iv值的即暂不需要支持加密的
        String decrypt = AESIVUtil.decrypt(password, getIv());
        return decrypt;
    }

}
